class Array

  def shift_while
    results = []
    while !empty? && yield(first)
      results << shift
    end
    results
  end

end
